package demo1;

public class TestDemo1  {

    public String toLowerCase(String s) {
//        return s.toLowerCase();
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            if(Character.isUpperCase(s.charAt(i))) {
                stringBuilder.append((char)(s.charAt(i) - 'A' + 'a'));
            } else {
                stringBuilder.append(s.charAt(i));
            }
        }
        return stringBuilder.toString();
    }
    public int countSegments(String s) {
        if(s.length() == 0) {
            return 0;
        }
        int count = 0;
        for(int i = 1; i < s.length(); i++) {
            if(s.charAt(i) == ' ' && s.charAt(i - 1) != ' ') {
                count++;
            }
        }
        if(s.charAt(s.length() - 1) != ' ') {
            count++;
        }
        return count;
    }
    public static void main(String[] args) {
        String s1 = "12dd3";
//        String s2 = "123";
//        System.out.println(s1 == s2);
        String s3 = "d";
        System.out.println(s1.contains(s3));
    }
}
